/**
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.solarchallenge.shared.dtos;

import com.google.solarchallenge.shared.ApplicantStatus;

/**
 * Data Transfer object for Applicant.
 *
 * @author Arjun Satyapal
 */
public class ApplicantDto implements AbstractDto {

  private String key;
  private UsAddressDto usAddress;
  private ApplicantStatus applicantStatus;

  private ApplicantDto() {
  }

  @Override
  public StringBuilder getStringBuilder() {
    return usAddress.getStringBuilder()
        .append(applicantStatus);
  }

  @Override
  public String toString() {
    return getStringBuilder().toString();
  }

  @Override
  public String validate() {
    StringBuilder builder = new StringBuilder("");

    if (usAddress == null) {
      builder.append("usAddress is null.\n");
    }

    return builder.toString();
  }

  public static class Builder {
    private String key;
    private UsAddressDto usAddress;
    private ApplicantStatus applicantStatus;

    public Builder setKey(String key) {
      this.key = key;
      return this;
    }

    public Builder setUsAddressDto(UsAddressDto usAddress) {
      this.usAddress = usAddress;
      return this;
    }

    public Builder setApplicantStatus(ApplicantStatus applicantStatus) {
      this.applicantStatus = applicantStatus;
      return this;
    }

    public ApplicantDto build() {
      ApplicantDto dto = new ApplicantDto();
      dto.key = this.key;
      dto.usAddress = this.usAddress;
      dto.applicantStatus = this.applicantStatus;
      dto.validate();
      return dto;
    }
  }

  public String getKey() {
    return key;
  }

  public UsAddressDto getUsAddressDto() {
    return usAddress;
  }

  public ApplicantStatus getApplicantStatus() {
    return applicantStatus;
  }
}
